﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using SmartSpace.Core;
using SmartSapce.ServiceLocation;
using SmartSpace.Packaging;

namespace SmartSpace.WebApp._console.core
{
    public partial class user_upload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #region upload user info
        protected void _ctlBtnImport_Click(object sender, EventArgs e)
        {
            Stream stream = new MemoryStream(_ctlFileXml.FileBytes);
            List<User> users = XUserUtil.Load(stream);
            ICoreService service = ServiceLocator.Get<ICoreService>();
            foreach (var item in users)
            {
                service.SaveUser(item);
            }

            Response.Redirect(_ctlLinkBack.NavigateUrl);
        }
        #endregion
    }
}